<?php
   class Pay_result extends MY_Controller{
	   public function __construct(){
		   parent::__construct();
		   $this->load->helper("url");
		   $this->load->model("model_pay");
		   $this->load->library('session');
		   $this->load->library('cart');
		   $this->load->helper('mail_helper');
		   $this->load->model("model_book");
	   }
	   public function pay_w(){
		   $SECURE_SECRET = "320395170BFA37E8AC63A78AF94E14FC";
			// get and remove the vpc_TxnResponseCode code from the response fields as we
			// Check $_GET haanhdon
			if(!isset($_GET['vpc_SecureHash'])){ $_GET['vpc_SecureHash'] = "";}
			if(!isset($_GET['vpc_TxnResponseCode'])){ $_GET['vpc_TxnResponseCode'] = "";}
			if(!isset($_GET['vpc_Amount'])){ $_GET['vpc_Amount'] = "";}
			if(!isset($_GET['vpc_Locale'])){ $_GET['vpc_Locale'] = "";}
			if(!isset($_GET['vpc_Command'])){ $_GET['vpc_Command'] = "";}
			if(!isset($_GET['vpc_Version'])){ $_GET['vpc_Version'] = "";}
			if(!isset($_GET['vpc_OrderInfo'])){ $_GET['vpc_OrderInfo'] = "";}
			if(!isset($_GET['vpc_Merchant'])){ $_GET['vpc_Merchant'] = "";}
			if(!isset($_GET['vpc_MerchTxnRef'])){ $_GET['vpc_MerchTxnRef'] = "";}
			if(!isset($_GET['vpc_TransactionNo'])){ $_GET['vpc_TransactionNo'] = "";}
			if(!isset($_GET['vpc_AcqResponseCode'])){ $_GET['vpc_AcqResponseCode'] = "";}
			if(!isset($_GET['vpc_BatchNo'])){ $_GET['vpc_BatchNo'] = "";}
			if(!isset($_GET['vpc_Message'])){ $_GET['vpc_Message'] = "";}	
			if(!isset($_GET['vpc_Card'])){ $_GET['vpc_Card'] = "";}	
			if(!isset($_GET['vpc_ReceiptNo'])){ $_GET['vpc_ReceiptNo'] = "";}	
			if(!isset($_GET['vpc_AcqResponseCode'])){ $_GET['vpc_AcqResponseCode'] = "";}				
			// do not want to include this field in the hash calculation
			$vpc_Txn_Secure_Hash = $_GET["vpc_SecureHash"];
			$vpc_MerchTxnRef = $_GET["vpc_MerchTxnRef"];
			$vpc_AcqResponseCode = $_GET["vpc_AcqResponseCode"];
			unset($_GET["vpc_SecureHash"]);
			// set a flag to indicate if hash has been validated
			$errorExists = false;
			
			if (strlen($SECURE_SECRET) > 0 && $_GET["vpc_TxnResponseCode"] != "7" && $_GET["vpc_TxnResponseCode"] != "No Value Returned") {
			
			    ksort($_GET);
			    //$md5HashData = $SECURE_SECRET;
			    //khởi tạo chuỗi mã hóa rỗng
			    $md5HashData = "";
			    // sort all the incoming vpc response fields and leave out any with no value
			    foreach ($_GET as $key => $value) {
			//        if ($key != "vpc_SecureHash" or strlen($value) > 0) {
			//            $md5HashData .= $value;
			//        }
			//      chỉ lấy các tham số bắt đầu bằng "vpc_" hoặc "user_" và khác trống và không phải chuỗi hash code trả về
			        if ($key != "vpc_SecureHash" && (strlen($value) > 0) && ((substr($key, 0,4)=="vpc_") || (substr($key,0,5) =="user_"))) {
					    $md5HashData .= $key . "=" . $value . "&";
					}
			    }
			//  Xóa dấu & thừa cuối chuỗi dữ liệu
			    $md5HashData = rtrim($md5HashData, "&");
			
			//    if (strtoupper ( $vpc_Txn_Secure_Hash ) == strtoupper ( md5 ( $md5HashData ) )) {
			//    Thay hàm tạo chuỗi mã hóa
				if (strtoupper ( $vpc_Txn_Secure_Hash ) == strtoupper(hash_hmac('SHA256', $md5HashData, pack('H*',$SECURE_SECRET)))) {
			        // Secure Hash validation succeeded, add a data field to be displayed
			        // later.
			        $hashValidated = "CORRECT";
			    } else {
			        // Secure Hash validation failed, add a data field to be displayed
			        // later.
			        $hashValidated = "INVALID HASH";
			    }
			} else {
			    // Secure Hash was not validated, add a data field to be displayed later.
			    $hashValidated = "INVALID HASH";
			}
			
			// Define Variables
			// ----------------
			// Extract the available receipt fields from the VPC Response
			// If not present then let the value be equal to 'No Value Returned'
			
			// Standard Receipt Data
			$amount = $this->null2unknown_w($_GET["vpc_Amount"]);
			$locale = $this->null2unknown_w($_GET["vpc_Locale"]);
			$batchNo = $this->null2unknown_w($_GET["vpc_BatchNo"]);
			$command = $this->null2unknown_w($_GET["vpc_Command"]);
			$message = $this->null2unknown_w($_GET["vpc_Message"]);
			$version = $this->null2unknown_w($_GET["vpc_Version"]);
			$cardType = $this->null2unknown_w($_GET["vpc_Card"]);
			$orderInfo = $this->null2unknown_w($_GET["vpc_OrderInfo"]);
			$receiptNo = $this->null2unknown_w($_GET["vpc_ReceiptNo"]);
			$merchantID = $this->null2unknown_w($_GET["vpc_Merchant"]);
			//$authorizeID = null2unknown($_GET["vpc_AuthorizeId"]);
			$merchTxnRef = $this->null2unknown_w($_GET["vpc_MerchTxnRef"]);
			$transactionNo = $this->null2unknown_w($_GET["vpc_TransactionNo"]);
			$acqResponseCode = $this->null2unknown_w($_GET["vpc_AcqResponseCode"]);
			$txnResponseCode = $this->null2unknown_w($_GET["vpc_TxnResponseCode"]);
			// 3-D Secure Data
			$verType = array_key_exists("vpc_VerType", $_GET) ? $_GET["vpc_VerType"] : "No Value Returned";
			$verStatus = array_key_exists("vpc_VerStatus", $_GET) ? $_GET["vpc_VerStatus"] : "No Value Returned";
			$token = array_key_exists("vpc_VerToken", $_GET) ? $_GET["vpc_VerToken"] : "No Value Returned";
			$verSecurLevel = array_key_exists("vpc_VerSecurityLevel", $_GET) ? $_GET["vpc_VerSecurityLevel"] : "No Value Returned";
			$enrolled = array_key_exists("vpc_3DSenrolled", $_GET) ? $_GET["vpc_3DSenrolled"] : "No Value Returned";
			$xid = array_key_exists("vpc_3DSXID", $_GET) ? $_GET["vpc_3DSXID"] : "No Value Returned";
			$acqECI = array_key_exists("vpc_3DSECI", $_GET) ? $_GET["vpc_3DSECI"] : "No Value Returned";
			$authStatus = array_key_exists("vpc_3DSstatus", $_GET) ? $_GET["vpc_3DSstatus"] : "No Value Returned";
			
			// *******************
			// END OF MAIN PROGRAM
			// *******************
			
			// FINISH TRANSACTION - Process the VPC Response Data
			// =====================================================
			// For the purposes of demonstration, we simply display the Result fields on a
			
			// web page.
			
			// Show 'Error' in title if an error condition
			$errorTxt = "";
			
			// Show this page as an error page if vpc_TxnResponseCode equals '7'
			if ($txnResponseCode == "7" || $txnResponseCode == "No Value Returned" || $errorExists) {
			    $errorTxt = "Error ";
			}
			
			// This is the display title for 'Receipt' page 
			//$title = $_GET["Title"];
			$transStatus = "";
			$infos = "";
			if($hashValidated=="CORRECT" && $txnResponseCode=="0"){
				$transStatus = "Your transaction is successful";
				$infos = "An email has been sent to you, please check your inbox for booking review. Thank you";
				$status = 1;
			}elseif ($hashValidated=="INVALID HASH" && $txnResponseCode=="0"){
				$transStatus = "Your transaction is pending";
				$status = 2;
			}else {
				$transStatus = "Failed transaction";
				$status = 3;
			}
			if($status == 1){ // thanh toán thành công
				$code = $_SESSION['ordercode'];
				if($code != NULL){
					$update_order = array("order_status" => "1");
					$filename = "Booking-wlinktravel.com-".date("m-d-Y-H-i-s");
					$file = "uploads/orderpdf/".$filename.".pdf";
					$this->model_pay->update_order($update_order,$code);
					$cruisename = $this->model_book->get_cruisename($_SESSION['ses_shipid']);
					$cruise_name = $cruisename['cruise_name'];
					$special = $cruisename['cruise_special'];
					$cancel  = $cruisename['cruise_cancel'];
					$pickup  = $cruisename['cruise_pickup'];
					$info    = $_SESSION['book_info'];
					$cart = unserialize($_SESSION['ses_total_cart']);
					foreach($cart as $items){
						$startdate=strtotime($items["options"]["startdate"]);
						$endate = strtotime($items["options"]["endate"]);
						$night = $items["options"]["rate_tour"] - 1;
						$abc = strtotime(date("Y-m-d",$startdate));
						$def = strtotime(date("Y-m-d",$endate));
						while($abc <= $def){
							$pricedate = date("Y-m-d",$abc);
							$this->model_pay->update_rooms($items['id'],$pricedate,$night);
							$abc+=86400;
						}
					}
					$this->createPDF($cart,$_SESSION['book_name'],$_SESSION['orderview'],$filename,$cruise_name,$special,$cancel,$pickup,$info);
					$this->sendmail($cart,$_SESSION['book_name'],$_SESSION['orderview'],$_SESSION['book_email'],$file,$cruise_name,$special,$cancel,$pickup,$info);
					session_destroy();
				}
			}
			$data['value'] = array(
				"trans_id" => $merchTxnRef,
				"trans_info" => $orderInfo,
				"trans_price" => $amount,
				"trans_result" => $txnResponseCode
			);
			$data['title']	= "Transaction status";
			$data['info'] = $infos;
			$data['status'] = $transStatus;
			$data['pay_status']	=  $this->getResponseDescription_w($txnResponseCode);
			$this->load->view("booking/status",$data);
	   }
		function null2unknown_w($data){
		    if ($data == "") {
		        return "No Value Returned";
		    } else {
		        return $data;
		    }
		}
		function getResponseDescription_w($responseCode){
		    switch ($responseCode) {
		        case "0" :
		            $result = "Transaction Successful";
		            break;
		        case "?" :
		            $result = "Transaction status is unknown";
		            break;
		        case "1" :
		            $result = "Bank system reject";
		            break;
		        case "2" :
		            $result = "Bank Declined Transaction";
		            break;
		        case "3" :
		            $result = "No Reply from Bank";
		            break;
		        case "4" :
		            $result = "Expired Card";
		            break;
		        case "5" :
		            $result = "Insufficient funds";
		            break;
		        case "6" :
		            $result = "Error Communicating with Bank";
		            break;
		        case "7" :
		            $result = "Payment Server System Error";
		            break;
		        case "8" :
		            $result = "Transaction Type Not Supported";
		            break;
		        case "9" :
		            $result = "Bank declined transaction (Do not contact Bank)";
		            break;
		        case "A" :
		            $result = "Transaction Aborted";
		            break;
		        case "C" :
		            $result = "Transaction Cancelled";
		            break;
		        case "D" :
		            $result = "Deferred transaction has been received and is awaiting processing";
		            break;
		        case "F" :
		            $result = "3D Secure Authentication failed";
		            break;
		        case "I" :
		            $result = "Card Security Code verification failed";
		            break;
		        case "L" :
		            $result = "Shopping Transaction Locked (Please try the transaction again later)";
		            break;
		        case "N" :
		            $result = "Cardholder is not enrolled in Authentication scheme";
		            break;
		        case "P" :
		            $result = "Transaction has been received by the Payment Adaptor and is being processed";
		            break;
		        case "R" :
		            $result = "Transaction was not processed - Reached limit of retry attempts allowed";
		            break;
		        case "S" :
		            $result = "Duplicate SessionID (OrderInfo)";
		            break;
		        case "T" :
		            $result = "Address Verification Failed";
		            break;
		        case "U" :
		            $result = "Card Security Code Failed";
		            break;
		        case "V" :
		            $result = "Address Verification and Card Security Code Failed";
		            break;
				case "99" :
		            $result = "User Cancel";
		            break;
		        default  :
		            $result = "Unable to be determined";
		    }
		    return $result;
		}
		public function createPDF($cart,$name,$number,$filename,$cruise,$special,$cancel,$pickup,$info){
			$services = unserialize($_SESSION['ses_services']);
			$ratetype = $_SESSION['rate'];
			$priall = $_SESSION['ses_cart_price'];
			if($ratetype == "vnd"){
				$priceall = round($priall/21000);
			}else{
				$priceall = $priall;
			}
			$cabin = "";
			$service = "";
			foreach($cart as $items){
				$cabin.=' 
				<style type="text/css">
					body{font:12px Verdana, Geneva, sans-serif;}
					h4{
						font:13px Verdana, Geneva, sans-serif;
						text-transform:uppercase
					}
				</style>
				<table>
				<tr><td><span style="font-weight:bold">Cabin type</span> <span style="float:right">:</span></td><td>'.$items['name'].'</td></tr>
				<tr><td>Number of Adults <span style="float:right">:</span></td><td>'.$items['options']['adults'].'</td></tr>
				<tr><td>Number of Children <span style="float:right">:</span></td><td>'.$items['options']['child'].'</td></tr>
				<tr><td>Number of Infants <span style="float:right">:</span></td><td>'.$items['options']['infants'].'</td></tr>';
				if($items['options']['extra'] != 0){
					$cabin.='
						<tr><td>Extra person <span style="float:right">:</span></td><td>'.$items['options']['extra'].'</td></tr>
					';
				}
				$cabin.='
				<tr><td>Check in <span style="float:right">:</span></td><td>'.$items['options']['startdate'].'</td></tr>
				<tr><td>Check out<span style="float:right">:</span></td><td>'.$items['options']['endate'].'</td></tr>
				</table>';
			}
			foreach($services as $serv){
			$service.='
			 <div style="float:left;width:100%;padding-top:8px;">
				<div style="float:left;text-align:justify;">'.$serv['val'].'</div>
			  </div>';
			}
			$html = '<style>a{text-decoration:none;}
						div{font-family:Tahoma, Geneva, sans-serif;}
						td{vertical-align:top; font-size:12px;font-family:Tahoma, Geneva, sans-serif;padding:2px 0px}
						ul li{font-size:12px;margin-bottom:4px}
						span {font-size:12px;}
						</style>
						<table width="100%" border="0" cellspacing="0" cellpadding="0">
							<tr>
								<td>
									<table width="100%" border="0" cellspacing="0" cellpadding="0">
										<tr>
											<td width="23%" valign="top"  style="border-bottom:1px #ccc solid;"><img src="public/images/logo.png" style="margin-top:-18px;margin-left:-10px" /></td>
											<td width="77%" style="text-align:right;border-bottom:1px #ccc solid;"><div style="float:left;width:100%;color:#C01A1A;font-size:33px;font-family:Times New Roman, Times, serif"> PRE-PAID VOUCHER </div>
										<a href="" style="margin-right:29px;color:#4e4e4e;"> <img src="http://paradisecruises.vn/images/print.gif" alt="Print Voucher" width="31" height="18" /><span style="font-size:12px;">Print voucher</span> </a> <a href="mailto:" style="margin-right:29px;color:#4e4e4e;"> <img src="http://paradisecruises.vn/images/mail.gif" alt="Email Voucher" width="27" height="18" /><span style="font-size:12px;">Email voucher</span> </a> <a href="mailto:info@wlinktravel.com" style="color:#4e4e4e;"> <img src="http://paradisecruises.vn/images/bestprint.gif" alt="Best Price Guarantee" width="22" height="18"/><span style="font-size:12px;">Best Price Guarantee</span> </a></td>
										</tr>
								   </table>
								   <hr />
								</td>
						  </tr>
						  <tr>
								<td>
									<table width="100%" border="0" cellspacing="0" cellpadding="0">
									<tr>
									<td valign="top" style="padding-right:20px;"><div style="float:left;width:345px;padding-left:35px;">
										<div style="float:left;width:200px;padding:18px 0 1px;color:#C01A1A;font-size:18px">Wlink Travel
										<hr style="color:#929292;margin-top:2px;"/>
									  </div>
										<table>
										<tr>
											<td style="color:#000;">Address <span style="float:right">:</span></td>
											<td>Units 08&09A, 3rd Floor, International Centre 
		17 Ngo Quyen Str., Hoan Kiem Dist., Hanoi, Vietnam</td>
										  </tr>
										<tr>
											<td>Phone <span style="float:right">:</span></td>
											<td>+84 43939 2929</td>
										  </tr>
										<tr>
											<td>Fax <span style="float:right">:</span></td>
											<td>+84 43936 8338</td>
										  </tr>
										<tr>
											<td>Email <span style="float:right">:</span></td>
											<td>info@wlinktravel.com</td>
										  </tr>
									  </table>
										<div style="float:left;width:100%;padding:86px 0 1px;color:#C01A1A;font-size:18px"> Special Requests
										<hr style="color:#929292;margin-top:2px;"/>
									  </div>
										<div style="float:left;width:100%;min-height:144px;">'.$info.'</div>
									  </div></td>
									<td valign="top"><div style="float:left;width:100%;padding:18px 0 1px;color:#C01A1A;font-size:18px">'.$cruise.' Reservation
										<hr style="color:#929292;margin-top:2px;"/>
									  </div>
										<table>
										<tr>
											<td style="color:#000;">Booking number <span style="float:right">:</span></td>
											<td>'.$number.'</td>
										  </tr>
										<tr>
											<td>Booker name <span style="float:right">:</span></td>
											<td>'.$name.'</td>
										  </tr>
									  </table>
										<div style="float:left;width:100%;padding-top:8px;">
										<div style="float:left; font-weight:bold;text-align:justify;">Cabin Confirmation:</div>
									  </div>
									  '.$cabin.'
									<div style="float:left;width:100%;padding-top:8px;">
									<div style="float:left;font-weight:bold;text-align:justify;">Transfer Service:</div>
								  </div>
									'.$service.'
									<table>
									<tr>
										<td>Total price:</td>
										<td style="float:right;font-weight:bold;font-size:16px;color:#C01A1A;"> $'.$priceall.'</td>
									  </tr>
									<tr>
										<td colspan="2" style="padding-top:8px;font-weight:bold;font-style:italic;">Note: VAT (10%) and Service charge (5%) included</td>
									  </tr>
								  </table></td>
							  </tr>
								<tr>
								<td valign="top" width="345px"  style="padding-right:20px;"><div style="float:left;width:345px;padding-left:35px;">
									<div style="float:left;width:100%;padding:18px 0 1px;color:#C01A1A;font-size:18px"> Important Note
									<hr style="color:#929292;margin-top:2px;"/>
								  </div>
									<div style="float:left;width:100%;min-height:144px;">'.$pickup.'</div>
								  </div></td>
								<td valign="top"><div style="float:right;padding-right:35px;width:345px;">
									<div style="float:left;width:100%;padding:18px 0 1px;color:#C01A1A;font-size:18px">Cancellation Policy
									<hr style="color:#929292;margin-top:2px;"/>
								  </div>
									<div style="min-height:100px;padding:10px 0px">
									<table width="400" border="0">
									  <tr>
										<td height="67">'.$cancel.'</td>
									  </tr>
									</table>
									</div>
									<div style="float:left;width:100%;padding:18px 0 1px;color:#C01A1A;font-size:18px">Special Check-in Instruction
									<hr style="color:#929292;margin-top:2px;"/>
								  </div>
									<div style="min-height:100px;padding-bottom:10px">'.$special.'</div>
								  </div></td>
							  </tr>
							  </table>
						   </td>
					   </tr>
					   <tr>
						   <td>
							  <div style="padding:0 35px;">
								 <div style="float:left;width:100%;padding:18px 0 1px;color:#C01A1A;font-size:18px">Need Help
									  <hr style="color:#929292;margin-top:2px;"/>
								 </div>
							  </div>
				  <table border="0" cellpadding="0" cellspacing="0">
							<tr>
								  <td>
										<div style="float:left;padding-top:8px;"> <span style="color:#000;">For any questions related to your reservation, please do feel free contact us directly on:<br>
										</span> <strong style="color:#C01A1A">+84 43939 2929</strong> (hotline number) or <br>
									  at <strong style="color:#C01A1A">info@wlinktravel.com</strong> </div></td>
								  <td width="300px">
										<div style="float:left;color:#11252f;font-size:28px;">Have a wonderful trip!</div></div>
								  </td>
							</tr>  
						  </table>
						</td>
				  </tr> 
				</table>';
					
			$this->load->library('Mpdf');
			//$name_pdf = date("dmYHis").rand();
			$mpdf = new Pdf();
			$mpdf->SetAutoFont(AUTOFONT_ALL);
			$mpdf->WriteHTML($html);
			$mpdf->Output("uploads/orderpdf/$filename.pdf",'F');
		}
		public function sendmail($cart,$name,$number,$email,$file,$cruises,$special,$cancel,$pickup,$info){
		   $mesnger = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
                    <html>
                    <head>
                    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
					<style type="text/css">
						body{font:12px Verdana, Geneva, sans-serif;}
						h4{
							font:13px Verdana, Geneva, sans-serif;
							text-transform:uppercase
						}
					</style>
                    </head>
                    <body>
                    <h2 style="font-size: 16px;">BOOKING FROM WLINK TRAVEL</h2>
                    <br/>
            ';
			$services = unserialize($_SESSION['ses_services']);
			$ratetype = $_SESSION['rate'];
			$priall = $_SESSION['ses_cart_price'];
			if($ratetype == "vnd"){
				$priceall = round($priall/21000);
			}else{
				$priceall = $priall;
			}
			$cabin = "";
			$service = "";
			foreach($cart as $items){
				$cabin.=' 
				<table>
				<tr><td><span style="font-weight:bold">Cabin type</span> <span style="float:right">:</span></td><td>'.$items['name'].'</td></tr>
				<tr><td>Number of Adults <span style="float:right">:</span></td><td>'.$items['options']['adults'].'</td></tr>
				<tr><td>Number of Children <span style="float:right">:</span></td><td>'.$items['options']['child'].'</td></tr>
				<tr><td>Number of Infants <span style="float:right">:</span></td><td>'.$items['options']['infants'].'</td></tr>';
				if($items['options']['extra'] != 0){
					$cabin.='
						<tr><td>Extra person <span style="float:right">:</span></td><td>'.$items['options']['extra'].'</td></tr>
					';
				}
				$cabin.='
				<tr><td>Check in <span style="float:right">:</span></td><td>'.$items['options']['startdate'].'</td></tr>
				<tr><td>Check out<span style="float:right">:</span></td><td>'.$items['options']['endate'].'</td></tr>
				</table>';
			}
			foreach($services as $serv){
			$service.='
			 <div style="float:left;width:100%;padding-top:8px;">
				<div style="float:left;text-align:justify;">'.$serv['val'].'</div>
			  </div>';
			}
			$mesnger.= '<style>a{text-decoration:none;}
						div{font-family:Tahoma, Geneva, sans-serif;}
						td{vertical-align:top; font-size:12px;font-family:Tahoma, Geneva, sans-serif;padding:2px 0px}
						ul li{font-size:12px;margin-bottom:4px}
						span {font-size:12px;}
						</style>
						<table width="100%" border="0" cellspacing="0" cellpadding="0">
							<tr>
								<td>
									<table width="100%" border="0" cellspacing="0" cellpadding="0">
										<tr>
											<td width="23%" valign="top"  style="border-bottom:1px #ccc solid;"><img src="http://wlinktravel.com/public/images/logo.png" style="margin-top:-18px;margin-left:-10px" /></td>
											<td width="77%" style="text-align:right;border-bottom:1px #ccc solid;"><div style="float:left;width:100%;color:#C01A1A;font-size:33px;font-family:Times New Roman, Times, serif"> PRE-PAID VOUCHER </div>
										<a href="" style="margin-right:29px;color:#4e4e4e;"> <img src="http://paradisecruises.vn/images/print.gif" alt="Print Voucher" width="31" height="18" /><span style="font-size:12px;">Print voucher</span> </a> <a href="mailto:" style="margin-right:29px;color:#4e4e4e;"> <img src="http://paradisecruises.vn/images/mail.gif" alt="Email Voucher" width="27" height="18" /><span style="font-size:12px;">Email voucher</span> </a> <a href="mailto:info@wlinktravel.com" style="color:#4e4e4e;"> <img src="http://paradisecruises.vn/images/bestprint.gif" alt="Best Price Guarantee" width="22" height="18"/><span style="font-size:12px;">Best Price Guarantee</span> </a></td>
										</tr>
								   </table>
								   <hr />
								</td>
						  </tr>
						  <tr>
								<td>
									<table width="100%" border="0" cellspacing="0" cellpadding="0">
									<tr>
									<td valign="top" style="padding-right:20px;"><div style="float:left;width:345px;padding-left:35px;">
										<div style="float:left;width:200px;padding:18px 0 1px;color:#C01A1A;font-size:18px">Wlink Travel
										<hr style="color:#929292;margin-top:2px;"/>
									  </div>
										<table>
										<tr>
											<td style="color:#000;">Address <span style="float:right">:</span></td>
											<td>Units 08&09A, 3rd Floor, International Centre 
		17 Ngo Quyen Str., Hoan Kiem Dist., Hanoi, Vietnam</td>
										  </tr>
										<tr>
											<td>Phone <span style="float:right">:</span></td>
											<td>+84 43939 2929</td>
										  </tr>
										<tr>
											<td>Fax <span style="float:right">:</span></td>
											<td>+84 43936 8338</td>
										  </tr>
										<tr>
											<td>Email <span style="float:right">:</span></td>
											<td>info@wlinktravel.com</td>
										  </tr>
									  </table>
										<div style="float:left;width:100%;padding:86px 0 1px;color:#C01A1A;font-size:18px"> Special Requests
										<hr style="color:#929292;margin-top:2px;"/>
									  </div>
										<div style="float:left;width:100%;min-height:144px;">'.$info.'</div>
									  </div></td>
									<td valign="top"><div style="float:left;width:100%;padding:18px 0 1px;color:#C01A1A;font-size:18px">'.$cruises.' Reservation
										<hr style="color:#929292;margin-top:2px;"/>
									  </div>
										<table>
										<tr>
											<td style="color:#000;">Booking number <span style="float:right">:</span></td>
											<td>'.$number.'</td>
										  </tr>
										<tr>
											<td>Booker name <span style="float:right">:</span></td>
											<td>'.$name.'</td>
										  </tr>
									  </table>
										<div style="float:left;width:100%;padding-top:8px;">
										<div style="float:left; font-weight:bold;text-align:justify;">Cabin Confirmation:</div>
									  </div>
									  '.$cabin.'
									<div style="float:left;width:100%;padding-top:8px;">
									<div style="float:left;font-weight:bold;text-align:justify;">Transfer Service:</div>
								  </div>
									'.$service.'
									<table>
									<tr>
										<td>Total price:</td>
										<td style="float:right;font-weight:bold;font-size:16px;color:#C01A1A;"> $'.$priceall.'</td>
									  </tr>
									<tr>
										<td colspan="2" style="padding-top:8px;font-weight:bold;font-style:italic;">Note: VAT (10%) and Service charge (5%) included</td>
									  </tr>
								  </table></td>
							  </tr>
								<tr>
								<td valign="top" width="345px"  style="padding-right:20px;"><div style="float:left;width:345px;padding-left:35px;">
									<div style="float:left;width:100%;padding:18px 0 1px;color:#C01A1A;font-size:18px"> Important Note
									<hr style="color:#929292;margin-top:2px;"/>
								  </div>
									<div style="float:left;width:100%;min-height:144px;">'.$pickup.'</div>
								  </div></td>
								<td valign="top"><div style="float:right;padding-right:35px;width:345px;">
									<div style="float:left;width:100%;padding:18px 0 1px;color:#C01A1A;font-size:18px">Cancellation Policy
									<hr style="color:#929292;margin-top:2px;"/>
								  </div>
									<div style="min-height:100px;padding-bottom:10px">'.$cancel.'</div>
									<div style="float:left;width:100%;padding:18px 0 1px;color:#C01A1A;font-size:18px">Special Check-in Instruction
									<hr style="color:#929292;margin-top:2px;"/>
								  </div>
									<div style="min-height:100px;padding-bottom:10px">'.$special.'</div>
								  </div></td>
							  </tr>
							  </table>
						   </td>
					   </tr>
					   <tr>
						   <td>
							  <div style="padding:0 35px;">
								 <div style="float:left;width:100%;padding:18px 0 1px;color:#C01A1A;font-size:18px">Need Help
									  <hr style="color:#929292;margin-top:2px;"/>
								 </div>
							  </div>
				  <table border="0" cellpadding="0" cellspacing="0">
							<tr>
								  <td>
										<div style="float:left;padding-top:8px;"> <span style="color:#000;">For any questions related to your reservation, please do feel free contact us directly on:<br>
										</span> <strong style="color:#C01A1A">+84 43939 2929</strong> (hotline number) or <br>
									  at <strong style="color:#C01A1A">info@wlinktravel.com</strong> </div></td>
								  <td width="300px">
										<div style="float:left;color:#11252f;font-size:28px;">Have a wonderful trip!</div></div>
								  </td>
							</tr>  
						  </table>
						</td>
				  </tr> 
				</table>';
		    $mesnger .= '</body></html> ';
			//return $mesnger;
			send_mail_helper($email, 'BOOKING FROM WLINK TRAVEL', htmlspecialchars_decode($mesnger),$file);
		}
   }